Skip to main content

Checklist for Microservices

Use the following checklist when dealing with a microservices architecture internally with DIT. This guide is intended for use among DIT software developers.

IDNameDescription
SMR-1AuthenticationCheck the presence of these two parameters in the request headers:
X-Auth-User
X-Auth-Signature

Verify the signature in X-Auth-Signature with a given public key.
SMR-2Database per service patternSeparate your microservice's database from the rest of the services.
SMR-3Events: Use Cloud Native EventsUse Cloud Native Events envelope format to publish messages to the message broker.
For the data property, use JSONAPI Specs (see SMR-9).
SMR-4Events: Idempotent ConsumersMake your consumers idempotent by processing messages with the same event id once.
SMR-5Events: Transactional OutboxMake publishing of events atomic along with operation applied on the corresponding resource.
SMR-6Events: Polling Publisher PatternHave a worker that uses polling to read unpublished messages and push them to the message broker
SMR-7Events: Single Exchange, Multiple Routing KeysUse a single exchange to publish message to a message broker, but utilize routing keys.
SMR-8Events: Follow Naming ConventionsUse the following convention to name your routing keys: Annex 1.1
Use the followiing convetnions to name your queues: Annex 1.2
SMR-9REST: Adopt JSON API SpecsFully adopt the JSONAPI Specs for responses.
SMR-10REST: JSONAPI Pagination ExtensionUse the following JSONAPI extension for pagination in responses: See Annex 2
SMR-11REST: JSONAPI Request ExtensionUse the following JSONAPI extension for requests: Annex 3
SMR-12REST: Async Request Reply PatternUse the Asynchronous Request Reply Pattern when dealing with computationally-intesive tasks that spans multiple microservices. See Annex 4.
The proper HTTP Code for this response is 202 ACCEPTED
SMR-13REST: Use Camel Case for JSONAPI Member NamesUse Camel Case for naming members in JSONAPI specs.
SMR-14REST: Use Idempotency KeyFor POST, DELETE and PATCH requests, require header Idempotency-Key to be present. Process requests with the same idempotency key only once.
SMR-15REST: Use Kebab-case for endpoint namesUse Kebab-case to name your REST endpoints.
SMR-16Use Open API for REST DocumentationUse Open API >= 3 to document REST endpoint
SMR-17Use AsyncAPI For Events DocumentationUse AsyncAPI >= 2 to document Events.
SMR-18Pagination must start from 1, not 0Pagination must start from page 1. This means that at Page 1, the offset is 0.

Annexes​

Annex 1​

  1. [api name]-api.[resource name in plural form].[operation type in past tense] Example: *users-api.users.created
  2. [api name]-api.[routing key of the listenting queue] Example: orders-api.users-api.users.created

Annex 2​

{
meta: {
pagination: {
totalPages: "integer"
count: "integer",
rowsPerPage: "integer",
page: "integer"
}
}
}

Annex 3​

{
data: {...request_payload}
}

Annex 4​

{
data: {
id: "string",
type: "async_request_responses",
attributes: {
retryAt: "string(datetime)",
location: "string"
}
}
}